\doxysection{C\+:/\+Users/\+ASUS/\+Desktop/dm-\/ctrl\+H7-\/balance-\/9025test/modules/algorithm/controller.h File Reference}
\hypertarget{controller_8h}{}\label{controller_8h}\index{C:/Users/ASUS/Desktop/dm-\/ctrlH7-\/balance-\/9025test/modules/algorithm/controller.h@{C:/Users/ASUS/Desktop/dm-\/ctrlH7-\/balance-\/9025test/modules/algorithm/controller.h}}
{\ttfamily \#include "{}main.\+h"{}}\newline
{\ttfamily \#include "{}stdint.\+h"{}}\newline
{\ttfamily \#include "{}memory.\+h"{}}\newline
{\ttfamily \#include "{}stdlib.\+h"{}}\newline
{\ttfamily \#include "{}bsp\+\_\+dwt.\+h"{}}\newline
{\ttfamily \#include "{}arm\+\_\+math.\+h"{}}\newline
{\ttfamily \#include $<$math.\+h$>$}\newline
\doxysubsubsection*{Classes}
\begin{DoxyCompactItemize}
\item 
struct \mbox{\hyperlink{struct_p_i_d___error_handler__t}{PID\+\_\+\+Error\+Handler\+\_\+t}}
\item 
struct \mbox{\hyperlink{struct_p_i_d_instance}{PIDInstance}}
\item 
struct \mbox{\hyperlink{struct_p_i_d___init___config__s}{PID\+\_\+\+Init\+\_\+\+Config\+\_\+s}}
\end{DoxyCompactItemize}
\doxysubsubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \mbox{\hyperlink{controller_8h_a3aa069ac3980707dae1e0530f50d59e4}{abs}}(x)
\end{DoxyCompactItemize}
\doxysubsubsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
\Hypertarget{controller_8h_a0bdc4b432004a7e3e2a483a7ee1567e0}\label{controller_8h_a0bdc4b432004a7e3e2a483a7ee1567e0} 
typedef enum error\+Type\+\_\+e {\bfseries Error\+Type\+\_\+e}
\end{DoxyCompactItemize}
\doxysubsubsection*{Enumerations}
\begin{DoxyCompactItemize}
\item 
\Hypertarget{controller_8h_a9ad7ec22a1ae28e9ee634a1bdd6e151e}\label{controller_8h_a9ad7ec22a1ae28e9ee634a1bdd6e151e} 
enum {\bfseries PID\+\_\+\+Improvement\+\_\+e} \{ \newline
{\bfseries PID\+\_\+\+IMPROVE\+\_\+\+NONE} = 0b00000000
, {\bfseries PID\+\_\+\+Integral\+\_\+\+Limit} = 0b00000001
, {\bfseries PID\+\_\+\+Derivative\+\_\+\+On\+\_\+\+Measurement} = 0b00000010
, {\bfseries PID\+\_\+\+Trapezoid\+\_\+\+Intergral} = 0b00000100
, \newline
{\bfseries PID\+\_\+\+Proportional\+\_\+\+On\+\_\+\+Measurement} = 0b00001000
, {\bfseries PID\+\_\+\+Output\+Filter} = 0b00010000
, {\bfseries PID\+\_\+\+Changing\+Integration\+Rate} = 0b00100000
, {\bfseries PID\+\_\+\+Derivative\+Filter} = 0b01000000
, \newline
{\bfseries PID\+\_\+\+Error\+Handle} = 0b10000000
 \}
\item 
\Hypertarget{controller_8h_aae6ca2c44670a2e62e916e460bd30554}\label{controller_8h_aae6ca2c44670a2e62e916e460bd30554} 
enum {\bfseries error\+Type\+\_\+e} \{ {\bfseries PID\+\_\+\+ERROR\+\_\+\+NONE} = 0x00U
, {\bfseries PID\+\_\+\+MOTOR\+\_\+\+BLOCKED\+\_\+\+ERROR} = 0x01U
 \}
\end{DoxyCompactItemize}
\doxysubsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
void \mbox{\hyperlink{controller_8h_a2f151ba2f498df613fea5f497aeac704}{PIDInit}} (\mbox{\hyperlink{struct_p_i_d_instance}{PIDInstance}} \texorpdfstring{$\ast$}{*}pid, \mbox{\hyperlink{struct_p_i_d___init___config__s}{PID\+\_\+\+Init\+\_\+\+Config\+\_\+s}} \texorpdfstring{$\ast$}{*}config)
\begin{DoxyCompactList}\small\item\em 初始化\+PID实例 \end{DoxyCompactList}\item 
float \mbox{\hyperlink{controller_8h_ac10c96e3f3e94b80d6df66c2c3ac53d0}{PIDCalculate}} (\mbox{\hyperlink{struct_p_i_d_instance}{PIDInstance}} \texorpdfstring{$\ast$}{*}pid, float measure, float ref)
\begin{DoxyCompactList}\small\item\em 计算\+PID输出 \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
\begin{DoxyAuthor}{Author}
Wang Hongxi 
\end{DoxyAuthor}
\begin{DoxyVersion}{Version}
V1.\+1.\+3 
\end{DoxyVersion}
\begin{DoxyDate}{Date}
2021/7/3 
\end{DoxyDate}
\begin{DoxyAttention}{Attention}

\end{DoxyAttention}


\label{doc-define-members}
\Hypertarget{controller_8h_doc-define-members}
\doxysubsection{Macro Definition Documentation}
\Hypertarget{controller_8h_a3aa069ac3980707dae1e0530f50d59e4}\index{controller.h@{controller.h}!abs@{abs}}
\index{abs@{abs}!controller.h@{controller.h}}
\doxysubsubsection{\texorpdfstring{abs}{abs}}
{\footnotesize\ttfamily \label{controller_8h_a3aa069ac3980707dae1e0530f50d59e4} 
\#define abs(\begin{DoxyParamCaption}\item[{}]{x}{}\end{DoxyParamCaption})}

{\bfseries Value\+:}
\begin{DoxyCode}{0}
\DoxyCodeLine{((x\ >\ 0)\ ?\ x\ :\ -\/x)}

\end{DoxyCode}


\label{doc-func-members}
\Hypertarget{controller_8h_doc-func-members}
\doxysubsection{Function Documentation}
\Hypertarget{controller_8h_ac10c96e3f3e94b80d6df66c2c3ac53d0}\index{controller.h@{controller.h}!PIDCalculate@{PIDCalculate}}
\index{PIDCalculate@{PIDCalculate}!controller.h@{controller.h}}
\doxysubsubsection{\texorpdfstring{PIDCalculate()}{PIDCalculate()}}
{\footnotesize\ttfamily \label{controller_8h_ac10c96e3f3e94b80d6df66c2c3ac53d0} 
float PIDCalculate (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{struct_p_i_d_instance}{PIDInstance}} \texorpdfstring{$\ast$}{*}}]{pid}{, }\item[{float}]{measure}{, }\item[{float}]{ref}{}\end{DoxyParamCaption})}



计算\+PID输出 


\begin{DoxyParams}{Parameters}
{\em pid} & PID实例指针 \\
\hline
{\em measure} & 反馈值 \\
\hline
{\em ref} & 设定值 \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
float PID计算输出
\end{DoxyReturn}
计算\+PID输出


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{in}}  & {\em PID结构体} & \\
\hline
\mbox{\texttt{in}}  & {\em 测量值} & \\
\hline
\mbox{\texttt{in}}  & {\em 期望值} & \\
\hline
\end{DoxyParams}

\begin{DoxyRetVals}{Return values}
{\em 返回空} & \\
\hline
\end{DoxyRetVals}
\Hypertarget{controller_8h_a2f151ba2f498df613fea5f497aeac704}\index{controller.h@{controller.h}!PIDInit@{PIDInit}}
\index{PIDInit@{PIDInit}!controller.h@{controller.h}}
\doxysubsubsection{\texorpdfstring{PIDInit()}{PIDInit()}}
{\footnotesize\ttfamily \label{controller_8h_a2f151ba2f498df613fea5f497aeac704} 
void PIDInit (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{struct_p_i_d_instance}{PIDInstance}} \texorpdfstring{$\ast$}{*}}]{pid}{, }\item[{\mbox{\hyperlink{struct_p_i_d___init___config__s}{PID\+\_\+\+Init\+\_\+\+Config\+\_\+s}} \texorpdfstring{$\ast$}{*}}]{config}{}\end{DoxyParamCaption})}



初始化\+PID实例 

\begin{DoxyRefDesc}{Todo}
\item[\mbox{\hyperlink{todo__todo000007}{Todo}}]待修改为统一的\+PIDRegister风格 \end{DoxyRefDesc}

\begin{DoxyParams}{Parameters}
{\em pid} & PID实例指针 \\
\hline
{\em config} & PID初始化配置\\
\hline
\end{DoxyParams}
初始化\+PID实例


\begin{DoxyParams}{Parameters}
{\em pid} & PID实例 \\
\hline
{\em config} & PID初始化设置 \\
\hline
\end{DoxyParams}
